package com.wang.learn.common.utils;

import org.springframework.stereotype.Controller;

import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;

/**
 * 类描述：
 *
 * @author Charles
 * @time 2021/10/8 11:39
 */

public class SafeStream {
    public SafeStream(){

    }

    public static <T> Stream<T> of(List<T> list){
        return list==null? Stream.empty():list.stream();
    }

    public static <T> Stream<T> of(Set<T> set){
        return set==null? Stream.empty():set.stream();
    }

    public static <T> Stream<T> of (T[] arr){
        return arr==null?Stream.empty():Stream.of(arr);
    }

    public static <T> Stream<T> of(Collection<T> collection){
        return collection==null?Stream.empty():collection.stream();
    }
}
